<?php

namespace app\common\model;

use think\Model;

class EqRelation extends Model
{
    public function add_one($info){
        $insert['alarm'] = $info['alarm'];
        $insert['video'] = $info['video'];
        $insert['display'] = 1;
        return $this->insertGetId($insert);
    }
    public function get_ong($alarm,$field='*'){
        $one =  $this->field($field)->where(['alarm'=>$alarm,'display'=>1])->find();
        if(!$one) return false;
        $one = model('Common/Equipment')->get_one($one['video'],['id','ins_id','name','code','address','lat','lng','type']);
        return $one;
    }
    public function get_video($video,$field='*'){
        $one =  $this->field($field)->where(['video'=>$video,'display'=>1])->find();
        if(!$one) return false;
        $one = model('Common/Equipment')->get_one($one['alarm'],['id','ins_id','name','code','address','lat','lng','type']);
        return $one;
    }

    public function del($alarm){
        return $this->where(['alarm'=>$alarm,'display'=>1])->update(['display'=>0]);
    }
}
